﻿using System;

using System.Collections.Generic;
using System.Text;
using Silvermoon.Visuals;
using System.IO;
using Silvermoon.OpenGL;
using System.Drawing;

namespace Silvermoon.Controls
{
    /// <summary>
    /// Control to display an Image.
    /// </summary>
    public class PictureBox : Control
    {
        #region fields

        private ImageVisual visual;

        #endregion
        #region ctor

        public PictureBox()
            : base()
        {
            visual = new ImageVisual();
            Visuals = new Visual[] { visual };
        }
        #endregion
        #region props

        public Color Color
        {
            get { return visual.Color; }
            set
            {
                if (visual.Color != value)
                {
                    visual.Color = Color;
                    Invalidate(InvalidationFlag.Color);
                }
            }
        }

        /// <summary>
        /// Gets or sets the image texture that holds an image.
        /// </summary>
        public Texture Image
        {
            get { return visual.Image; }
            set
            {
                if (visual.Image != value) { visual.Image = value; Invalidate(InvalidationFlag.LayoutAppearance); }
            }
        }

        #endregion
        #region Methods


        protected override void OnLayout()
        {
            visual.Size = Control.Scale(Size);
            base.OnLayout();
        }

        #endregion
    }
}
